﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NLog;
using NGinnBPM.Lib.Interfaces;
using NGinnBPM.MessageBus.Impl.HttpService;
using NGinnBPM.MessageBus;
using System.IO;
using NGinnBPM.Lib.Schema;

namespace NGinnBPM.Services.Website
{
    
    [UrlPattern(@"^/processdef/(?<id>.+)?")]
    public class ProcessDefinitionServlet : ServletBase
    {
        public IProcessPackageRepository PackageRepository { get; set; }

        public override void HandleRequest(IRequestContext ctx)
        {
            ctx.ResponseContentType = "text/html";
            string pkg;
            if (ctx.UrlVariables.TryGetValue("id", out pkg) && pkg.Length > 0)
            {
                OutputProcessInfo(pkg, ctx);
            }
            else
            {
                ctx.Output.WriteLine("<html><body><div>Please specify process definition ID</div></body></html>");
            }
        }

        protected void OutputProcessInfo(string definitionId, IRequestContext ctx)
        {
            ProcessDefinition pd = PackageRepository.GetProcess(definitionId);
        }
    }
}
